package admincow.servlet.produccion;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import admincow.dao.ProduccionDAO;
import admincow.vo.ProduccionVO;

/**
 * Servlet implementation class for Servlet: UsuarioModificarServlet
 * 
 */
public class ProduccionModificarServlet extends javax.servlet.http.HttpServlet
		implements javax.servlet.Servlet {
	static final long serialVersionUID = 1L;

	/*
	 * (non-Java-doc)
	 * 
	 * @see javax.servlet.http.HttpServlet#HttpServlet()
	 */
	public ProduccionModificarServlet() {
		super();
	}

	/*
	 * (non-Java-doc)
	 * 
	 * @see javax.servlet.http.HttpServlet#doGet(HttpServletRequest request,
	 *      HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

	/*
	 * (non-Java-doc)
	 * 
	 * @see javax.servlet.http.HttpServlet#doPost(HttpServletRequest request,
	 *      HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {

		String a = request.getParameter("idproduc");
		System.out.println(a);
		String b = request.getParameter("rpvaca");
		String c = request.getParameter("primer_ord");
		String d = request.getParameter("segundo_ord");
		String e = request.getParameter("tercer_ord");
		String f = request.getParameter("total_ord");
		String g = request.getParameter("prec_litro");
		String h = request.getParameter("precio");
		String i = request.getParameter("fecha");


		ProduccionVO vo = new ProduccionVO();
		vo.setIdproduc(Integer.parseInt(a) );
		vo.setRPvaca(b);
		vo.setPrimer_ord(Float.parseFloat(c));
		//vo.setPrimer_ord(Integer.parseInt(c));
		vo.setSegundo_ord(Float.parseFloat(d));
		vo.setTercer_ord(Float.parseFloat(e));
		vo.setTotal_ord(Float.parseFloat(f));
		vo.setPrec_litro(Float.parseFloat(g));
		vo.setPrecio(Float.parseFloat(h));
		vo.setFecha(i);
		
		ProduccionDAO dao = new ProduccionDAO();
		dao.actualizar(vo);

		RequestDispatcher rd = request
				.getRequestDispatcher("/produccionBuscar.jsp");
		rd.forward(request, response);

	}
}